<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Models
 *
 * @author mrquang
 */

include '../config.php';
class Models {
    //put your code here
    
public $db;
    public function __construct()
    {
      
        
        
        $this->db=  mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
       
        
    }
    
    public function getAll()
    {
        $sql = "SELECT * FROM `tbd_user`";
        $sq=  mysqli_query($this->db, $sql);
        $a='';
        
        
        
       return $sq;
       
        
    }
    public function login($username,$password)
    {
            $password=  md5($password);
          $sql="select * from tbd_user where Name='$username' and Password='$password'";
          $sq=mysqli_query($this->db, $sql);
          return $sq ;
    }
    public function insertUser($Name,$UserName,$Password,$Level="1",$Admin="1",$Active="1",$Ord="1")
    {
        $Password=  md5($Password);
        $sql="INSERT INTO `tbd_user`(`Name`, `UserName`, `Password`, `Level`, `Admin`, `Ord`, `Active`) VALUES ('$Name','$UserName','$Password','$Level','$Admin','$Ord','$Active')";
         $sq=mysqli_query($this->db, $sql);
        
    }

    public function __destruct() {
        
        
    }
}
?>
